//C10:StaticDestructors.cpp
// Static object destructors
#include <fstream>
using namespace std;
ofstream out("stadest.out");  // Trace file

class Obj
{
    char c;    // Indentifier
    public:
        Obj(char cc): c(cc)
        {
            out << "Ojb::Obj() for " << c << endl;
        }
        ~Obj()
        {
            out << "Obj::~Obj() for " << c << endl;
        }
};

Obj a('a'); // Global (static storage)
// Constructor & destructor always called
void f()
{
    static Obj b('b');
}

void g()
{
    static Obj c('c');
}

int main(void)
{
    out << "inside main()" << endl;
    f();   // Calls static construtor for b
    // g() not called
    out << "leaving main()" << endl;
}